import request from '@/utils/request'

const ROLE_URL = '/resource'
const SUBSYSTEM_URL = '/subsystem'

export function getSubsystem(subSystemQuery) {
  return request({
    url: SUBSYSTEM_URL,
    method: 'get',
    params: subSystemQuery
  })
}

export function getMenu() {
  return request({
    url: ROLE_URL + '/Menu',
    method: 'get'
  })
}
export function add(ResourceDTO) {
  return request({
    url: ROLE_URL,
    method: 'post',
    data: ResourceDTO
  })
}

export function remove(id, version) {
  return request({
    url: ROLE_URL,
    method: 'delete',
    params: { id: id, version: version }
  })
}

export function batchRemove(ResourceDTOs) {
  return request({
    url: ROLE_URL + '/batch',
    method: 'delete',
    data: ResourceDTOs
  })
}

export function modify(ResourceDTO) {
  return request({
    url: ROLE_URL,
    method: 'put',
    data: ResourceDTO
  })
}
export function getModifyInfo(id) {
  return request({
    url: ROLE_URL + `/${id}`,
    method: 'get'
  })
}

export function copy(id) {
  return request({
    url: ROLE_URL + '/copy',
    method: 'post',
    params: { 'id': id }
  })
}

export function commonQuery(ResourceQuery) {
  return request({
    url: ROLE_URL,
    method: 'get',
    params: ResourceQuery
  })
}

export function treeQuery(ResourceQuery) {
  return request({
    url: ROLE_URL + '/getALL',
    method: 'get',
    params: ResourceQuery
  })
}

export function Query(Query) {
  return request({
    url: '/subsystem',
    method: 'get',
    params: Query
  })
}

export function querySubSystemById(id) {
  return request({
    url: '/subsystem/' + id,
    method: 'get'
  })
}

export function queryResourceById(id) {
  return request({
    url: ROLE_URL + '/' + id,
    method: 'get'

  })
}
